/*
 * 创建日期 2009-11-11
 *
 * 成都天和软件公司
 * 电话：028-85425861
 * 传真：028-85425861-8008
 * 邮编：610041 
 * 版权所有
 */
package  org.fantasy.cpp.core.html.query;

import javax.servlet.http.HttpServletRequest;

import  org.fantasy.cpp.core.bean.ParamContext;
import  org.fantasy.common.util.StringUtil;

/**
 *  简单文本框
 * @author: 王文成
 * @version: 1.0
 * @since 2009-11-11
 */
public class TextHtml extends AbstractQueryHtml {

	public TextHtml(HttpServletRequest request, ParamContext param) {
		super(request, param);
	}

	public String getHtml() {
		StringBuffer html = new StringBuffer(1024);
		html.append("<span class='" + SPAN_CLASS + "'>");
		html.append(getLabelName());
		html.append("<input class=\"content_inputtab\" id='" + code + "'"
				+ getClassHtml() + getStyleHtml()  + getIsReadonly(code) + getAutoQuery()
				+ " type='text'  name='" + code + "' value='" + defValue + "'/>");
		html.append("</span>");
		html.append(getImport());
		html.append(getLike());
		return html.toString();
	}

	/**
	 * 生成模糊查询支持
	 * 
	 * @return
	 */
	private String getLike() {
		if (!param.isTrue(LIKE))
			return "";
		String isLikeName = "isLike" + StringUtil.firstCharUpperCase(code);
		String ckbIsLikeName = "ckb" + StringUtil.firstCharUpperCase(isLikeName);
		StringBuffer html = new StringBuffer(512);
		html.append("<input type=\"hidden\"  name=\"" + ckbIsLikeName + "\" value=\"true\"/> \n");
		html.append("<span class='" + SPAN_CLASS + "'><select id='" + isLikeName + "' name='" + isLikeName
				+ "'> \n");
		html.append("<option value='false'>精确查询</option> \n");
		html.append("<option value='true'>模糊查询</option> \n");
		html.append("</select></span>\n");
		return html.toString();
	}

	/**
	 * 生成导出
	 * 
	 * @return
	 */
	private String getImport() {
		if (!param.isTrue(IMPORT))
			return "";
		String ctx = request.getContextPath();
		StringBuffer html = new StringBuffer(128);
		html.append("<span class='" + SPAN_CLASS + "'><img src=\"" + ctx
				+ "/images/file.png\" align=\"absmiddle\" onClick=\"_ImportFile('" + code + "')\"/></span>\n");
		return html.toString();
	}
}
